package com.baizhi.service;

import com.baizhi.annotation.LogAnnotation;
import com.baizhi.dao.GuruDao;
import com.baizhi.entrty.Guru;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service

public class GuruServiceImpl implements GuruService {
    private Logger logger = LoggerFactory.getLogger(GuruServiceImpl.class);
    @Autowired

    private GuruDao gd;

    //@LogAnnotation
    @Override
    public Map fy(int page, int rows) {

        logger.info("上师分页开始");

        int count = gd.getCount();
        int start = (page-1)*rows;

        Map map = new HashMap();
        List<Guru> list = gd.getGuru(start,rows);

        map.put("total",count);
        map.put("rows",list);
        logger.info("上师分页结束");
        return map;
    }

    @Override
    public void insert(Guru gu) {
        logger.info("上师添加开始");
        gd.insert(gu);
        logger.info("上师添加结束");
    }

    @Override
    public void jd(int[] id) {
        logger.info("上师冻结开始");
        gd.dj(id);
        logger.info("上师冻结结束");
    }

    @Override
    public void dj(int[] id) {
        logger.info("上师解冻开始");
        gd.jd(id);
        logger.info("上师解冻结束");
    }


}
